import React from "react";
import PropTypes from "prop-types";
import classNames from "classnames";
import styles from "./index.less";

const GlobalFooter = ({ className, links, copyright }) => {
  const clsString = classNames(styles.globalFooter, className);
  return (
    <div className={clsString}>
      {links && (
        <div className={styles.links}>
          {links.map(link => (
            <a
              key={link.key}
              target={link.blankTarget ? "_blank" : "_self"}
              href={link.href}
            >
              {link.title}
            </a>
          ))}
        </div>
      )}
      {copyright && <div className={styles.copyright}>{copyright}</div>}
    </div>
  );
};

if (process.env.UMI_ENV !== "prod") {
  GlobalFooter.propTypes = {
    className: PropTypes.string.isRequired,
    links: PropTypes.array.isRequired,
    copyright: PropTypes.string.isRequired
  };
}

GlobalFooter.defaultProps = {
  className: "",
  links: [],
  copyright: ""
};

export default GlobalFooter;
